﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Tools;

namespace Punia
{
    [CommandAttribute(false)]
    public partial class drop_route : BaseForm
    {
        public drop_route()
            : base()
        {
        }

        public drop_route(DbContext dbContext)
            :base(dbContext)
        {
            InitializeComponent();

            cbRoute.DataSource = Utility.routes(dbContext);
            cbRoute.DisplayMember = "Name";

            cbRoute.SelectedIndexChanged += new EventHandler(cbRoute_SelectedIndexChanged);
        }

        void cbRoute_SelectedIndexChanged(object sender, EventArgs e)
        {
            Write();
        }

        protected override void Write()
        {
            StringBuilder sb = new StringBuilder();

            if (cbRoute.SelectedIndex > 0)
            {
                sb.AppendLine("DROP ROUTE [" + cbRoute.Text + "]");
            }

            tbCommand.Text = sb.ToString();
        }
    }
}